package plus.xj17520.org.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import plus.xj17520.base.query.ShopQuery;
import plus.xj17520.base.result.JSONResult;
import plus.xj17520.org.domain.Shop;
import plus.xj17520.org.domain.ShopRegisterDTO;
import plus.xj17520.org.service.IShopService;

/**
 * @projectName: pethomeProject
 * @package: plus.xj17520.org.controller
 * @className: ShopRegister
 * @author: XiaoJue
 * @description: TODO
 * @date: 2022/5/29 10:09
 * @version: 1.0
 */
@RestController
@RequestMapping("shop")
public class ShopController {
    @Autowired
    private IShopService shopService;


    /**
     * 分页，精确根据state查找，列表显示所有满足条件数据
     *
     * @param shopQuery
     * @return
     */
    @PostMapping("query")
    public JSONResult query(@RequestBody ShopQuery shopQuery) {
        return shopService.shopPageList(shopQuery);
    }
//
//    @PostMapping("batchDelete")
//    public JSONResult batchDelete(@RequestBody ShopQuery shopQuery){
//        return shopService.batchDelete(shopQuery);
//    }
//

    /**
     * 商家店铺激活，点击邮件中的链接激活店铺
     *
     * @param uuid
     * @return
     */
    @GetMapping("activate/{uuid}")
    public JSONResult activate(@PathVariable String uuid) {
        return shopService.activate(uuid);
    }

    /**
     * 注册店铺，前端有员工表信息，店铺表信息
     *
     * @param dto
     * @return
     */
    @PostMapping("register")
    public JSONResult register(@RequestBody ShopRegisterDTO dto) {
        return shopService.register(dto);
    }

    /**
     * 前台审核通过，发送邮件给商户进行店铺激活操作
     *
     * @param id
     * @return
     */
    @GetMapping("auditYes/{id}")
    public JSONResult auditYes(@PathVariable Long id) {
        return shopService.auditYes(id);
    }

    /**
     * 前台审核驳回，发送邮件给商户驳回理由
     *
     * @param shop
     * @return
     */
    @PostMapping("auditNo")
    public JSONResult auditNo(Shop shop) {
        return shopService.auditNo(shop);
    }
}
